CFLAGS = -Wall -fpic -coverage -lm

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)
	
cardTest1.o: cardTest1.h cardTest1.c dominion.o rngs.o
	gcc -c  cardTest1.c -g $(CFLAGS)
	
cardTest2.o: cardTest2.h cardTest2.c dominion.o rngs.o
	gcc -c  cardTest2.c -g $(CFLAGS)
	
cardTest3.o: cardTest3.h cardTest3.c dominion.o rngs.o
	gcc -c  cardTest3.c -g $(CFLAGS)
	
cardTest4.o: cardTest4.h cardTest4.c dominion.o rngs.o
	gcc -c  cardTest4.c -g $(CFLAGS)
	
unitTest1.o: unitTest1.h unitTest1.c dominion.o rngs.o
	gcc -c  unitTest1.c -g $(CFLAGS)
		
unitTest2.o: unitTest2.h unitTest2.c dominion.o rngs.o
	gcc -c  unitTest2.c -g $(CFLAGS)
	
unitTest3.o: unitTest3.h unitTest3.c dominion.o rngs.o
	gcc -c  unitTest3.c -g $(CFLAGS)
	
unitTest4.o: unitTest4.h unitTest4.c dominion.o rngs.o
	gcc -c  unitTest4.c -g $(CFLAGS)
	
randomtestadventurer: randomtestadventurer.c dominion.o rngs.o
	gcc -o randomtestadventurer -g  randomtestadventurer.c dominion.o rngs.o $(CFLAGS)
	
randomtestcard: randomtestcard.c dominion.o rngs.o
	gcc -o randomtestcard -g  randomtestcard.c dominion.o rngs.o $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

runtests: testDrawCard 
	./testDrawCard &> unittestresult.out
	gcov dominion.c >> unittestresult.out
	cat dominion.c.gcov >> unittestresult.out
	
tests: tests.c  dominion.o rngs.o cardTest1.o cardTest2.o cardTest3.o cardTest4.o unitTest1.o unitTest2.o unitTest3.o unitTest4.o
	gcc -o tests -g  tests.c  dominion.o rngs.o cardTest1.o cardTest2.o cardTest3.o cardTest4.o unitTest1.o unitTest2.o unitTest3.o unitTest4.o $(CFLAGS)
	
unittestresults.out: tests
	rm -f unittestresults.out
	./tests &> unittestresults.out
	gcov -b -c dominion.c >> unittestresults.out
	cat dominion.c.gcov >> unittestresults.out	
	
randomtestadventurer.out: randomtestadventurer
	rm -f randomtestadventurer.out
	./randomtestadventurer &> randomtestadventurer.out
	gcov -b -c dominion.c >> randomtestadventurer.out
	cat dominion.c.gcov >> randomtestadventurer.out	
	
randomtestcard.out: randomtestcard
	rm -f randomtestadventurer.out
	./randomtestcard &> randomtestcard.out
	gcov -b -c dominion.c >> randomtestcard.out
	cat dominion.c.gcov >> randomtestcard.out	

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

all: playdom player testDrawCard testBuyCard badTestDrawCard tests

clean:
	rm -f *.o playdom.exe playdom tests testDrawCard badTestDrawCard testBuyCard testAll test.exe test player player.exe testInit testInit.exe *.gcov *.gcda *.gcno *.so 
	rm -r *.dSYM
